#include<bits/stdc++.h>
using namespace std;

int N, Q;
string S;

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> N >> Q >> S;
	vector<int> a(N, 0);
	for(int i=1;i<N;++i){
		if(S[i - 1] == S[i]){
			a[i] = a[i - 1] + 1;
		}else{
			a[i] = a[i - 1];
		}
	}
	for(int s,e,q=1;q<=Q;++q){
        cin >> s >> e;
		--s; --e;
		cout << a[e] - a[s] << endl;
	}
 	return 0;
}